package com.corewillsoft.fireflies.gamelaws;

import com.corewillsoft.fireflies.gameobjects.Firefly;
import com.corewillsoft.fireflies.gameobjects.GameObject;

public class GravityLaw extends BaseLaw {

	private final static float LAW_FORCE = 1.5f;

	@Override
	public void applicate(GameObject gameObject) {
		if (gameObject instanceof Firefly) {
			applicateFirefly((Firefly) gameObject);
		} else {
			gameObject.setPosition(gameObject.getX(), gameObject.getY() + LAW_FORCE);
		}
	}

	private void applicateFirefly(Firefly firefly) {
		if (!firefly.isSaved()) {
			firefly.setPosition(firefly.getX(), firefly.getY() + LAW_FORCE);
		}
	}

	@Override
	public LawType getType() {
		return LawType.GRAVITY;
	}
}
